
#ifndef _MEMBER_BTABLEWIDGET_H_
#define _MEMBER_BTABLEWIDGET_H_

#include <ctime>
#include <BPainter>
#include <BFont>
#include <BTable>
#include <BLabel>
#include <BLineEdit>
#include <BTableItem>
#include <BSizePolicy>
#include <BTableWidget>

#include "IHeader.h"
#include "member_BTableItem.h"

#define table_member(table)		((member_BTableWidget*)((BTableWidget*)table)->_ptr)

namespace BWE
{
	class member_BTableWidget : public BObject
	{
	public:
		member_BTableWidget(BTableWidget* boss);
		~member_BTableWidget();

		BTableItem* itemAtPoint(const BPoint& pos);

		void freshColumnHeader(const BStyle* style);
		void freshRowHeader(const BStyle* style);

		void adjustHeader();
		void adjustItemRects();
		bool selectItemsInside();
		bool sortColumn(int column);

	public:
		BTableWidget*			boss;
		GridStyle				gridStyle;
		SelectMode				selectMode;
		BSize					iconSize;

		bool					dirty;
		bool					selecting;
		BPoint					pressedPoint;
		BRect					selectRect;
		BTableItem*				hoverItem;
		BTableItem*				shiftItem;
		BPoint					selectedPos;
		clock_t					selectedTime;
		IHeader					rowHeader;
		IHeader					columnHeader;
		BStyleHolder			headerStyle;
		BStyleHolder			itemStyle;

		BArray<BTableItem*>			selectedItems;
		BArray<BTableItem*>			visualItems;
		BTable<BTableItemHolder>	items;
	};
}

#endif